﻿Imports Microsoft.DirectX.Direct3D
Imports Microsoft.DirectX
Public Class ObjektLabel
    Inherits Objekt2D
    Public Text As ObjektText
    Dim CanbeDraw3D As Boolean = False
    Public Sub New(ByVal X As Integer, ByVal Y As Integer, ByVal Bild As String, ByVal Text() As String, ByVal Textposition As Point, ByVal Schriftgroesse As Integer, ByVal neuFrames As Integer, ByVal Fixed As PointF, Optional ByVal Handler As ObjektPanel = Nothing, Optional ByVal CanbeDraw3D As Boolean = False)
        MyBase.New(Bild, New Rectangle(X, Y, Image.FromFile(Bild).Width / (neuFrames + 1), Image.FromFile(Bild).Height), New Point(X, Y), Fixed, Handler)
        MaxeFrame = New Point(neuFrames, 0)
        Dim T(Text.Length - 1) As String
        For I = 0 To T.Length - 1
            T(I) = Sprachconverter.Translate(Text(I))
        Next

        Me.CanbeDraw3D = CanbeDraw3D
        Me.Text = New ObjektText(T, Textposition.X, Textposition.Y, Nothing, Schriftengine.Schriftarten.Arial, Schriftgroesse, FontStyle.Regular)
        If Not CanbeDraw3D Then
            Bildgroesse = New Rectangle(Bildgroesse.Location, Me.Text.GetSchriftart.MeasureString(Schriftengine.MeasureSprite, Text(0), DrawTextFormat.None, Color.Black).Size)
        End If
    End Sub

    Public Overrides Function Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
        Return False
    End Function

    Public Overrides Function KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
        Return False
    End Function

    Public Overrides Function MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) As Boolean
        Return False
    End Function

    Public Overrides Function MouseEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) As Boolean
        Return False
    End Function

    Public Overrides Function MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) As String
        Return ""
    End Function
    Public Overrides Sub Malen()
        Dim Pos As Point
        If CanbeDraw3D And (DataSettings.draw3D Or DataSettings._2D_3D_Malen) Then
            Dim Vec As New Vector3(Hauptmenue.SpielfeldPunkt.X + 0.5, 0, -Hauptmenue.SpielfeldPunkt.Y)
            Pos = Grafikengine.WorldSpaceToScreenSpace(Vec)
            Pos.X -= Hauptmenue.FeldbreiteKlein
            Pos.Y -= +24 + Hauptmenue.Feldbreite
        Else
            Pos = Koordinatene
        End If

        If Handler IsNot Nothing Then
            If Not Handler.IsVisible(New Rectangle(Pos.X, Pos.Y, Rechteck.Width, Rechteck.Height), True) Then
                Exit Sub
            End If
        End If
        Dim sngRotation As Double = 0
        Dim intColor As Color = Color.FromArgb(255, 255, 255, 255)
        With Grafikengine.recBild
            .X = Frame.X * Rechteck.Width : .Width = Rechteck.Width
            .Y = 0 : .Height = Rechteck.Height
        End With
        Grafikengine.ptfRotCenter = New Point(0, 0)
        Grafikengine.ptfPosition = GetRealKoordinaten() - Koordinatene + Pos
        With Grafikengine.szfScale
            .Width = Rechteck.Width
            : .Height = Rechteck.Height
        End With
        Grafikengine.Sprite.Draw2D(Textur.getTextur(TexturID), Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
        If IsNothing(Text) = False Then
            Text.Malen(Grafikengine.ptfPosition)
        End If
        Frame = New Point(Frame.X + 1, Frame.Y)
        If IsNothing(Text) = False Then
            Text.Malen(Grafikengine.ptfPosition)
        End If
    End Sub

    Public Overloads Overrides Function MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) As Boolean

    End Function
End Class
